package com.ykt.converter;

import com.ykt.common.utils.UB;
import com.ykt.model.MediaSource;
import com.ykt.vo.MediaSourceVo;

import java.util.ArrayList;
import java.util.List;

/**
 * @author long.hua
 * @version 1.0.0
 * @since 2016-05-25 00:04
 */
public class MediaSourceConverter {


    public static MediaSourceVo convert(MediaSource model){
        MediaSourceVo vo = new MediaSourceVo();
        BaseConverter.convert(vo, model);

        vo.setBizType(model.getStr(MediaSource.biz_type));
        vo.setBizSubType(model.getStr(MediaSource.biz_sub_type));
        vo.setBizId(UB.i(model.getInt(MediaSource.biz_id)));
        vo.setMediaType(model.getStr(MediaSource.media_type));
        vo.setCover(model.getStr(MediaSource.cover));
        vo.setContent(model.getStr(MediaSource.content));
        vo.setSort(UB.i(model.get(MediaSource.sort)));

        return vo;
    }

    public static List<MediaSourceVo> convert(List<MediaSource> models){
        List<MediaSourceVo> vos = new ArrayList<>();
        if(models == null || models.isEmpty()){
            return vos;
        }

        for (MediaSource model : models) {
            if(model != null){
                vos.add(convert(model));
            }
        }

        return vos;
    }

}
